-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[Docs Site] Use Tippy.js for footnotes #17357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| mermaid.initialize({ startOnLoad: false, theme }); | ||
| await mermaid | ||
| .render(`mermaid-${crypto.randomUUID()}`, def) | ||
| .then(({ svg }) => (diagram.innerHTML = svg)); |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the content being inserted into innerHTML is properly sanitized. Since the mermaid.render function is used to generate the SVG content, we should ensure that this content is safe. If mermaid does not guarantee the safety of its output, we should sanitize the SVG content before inserting it into the DOM.
The best way to fix this without changing existing functionality is to use a library like DOMPurify to sanitize the SVG content before setting it as innerHTML. This ensures that any potentially harmful content is removed.
-
Copy modified line R2 -
Copy modified line R24
| @@ -1,2 +1,3 @@ | ||
| import mermaid from "mermaid"; | ||
| import DOMPurify from "dompurify"; | ||
|
|
||
| @@ -22,3 +23,3 @@ | ||
| .render(`mermaid-${crypto.randomUUID()}`, def) | ||
| .then(({ svg }) => (diagram.innerHTML = svg)); | ||
| .then(({ svg }) => (diagram.innerHTML = DOMPurify.sanitize(svg))); | ||
|
|
-
Copy modified lines R86-R89
| @@ -85,3 +85,6 @@ | ||
| "node": "22.8.0" | ||
| } | ||
| }, | ||
| "dependencies": { | ||
| "dompurify": "^3.1.7" | ||
| } | ||
| } |
| Package | Version | Security advisories |
| dompurify (npm) | 3.1.7 | None |
|
Closes #16250 |
Deploying cloudflare-docs with
|
| Latest commit: |
1e454fd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://038f916d.cloudflare-docs-7ou.pages.dev |
| Branch Preview URL: | https://kian-pcx-13959.cloudflare-docs-7ou.pages.dev |
|
Files with changes (up to 15)
|
* [Docs Site] Use Tippy.js for footnotes * tabindex/hover cutoff fixes * update style guide link to lib * new fnref styling
* [Docs Site] Use Tippy.js for footnotes * tabindex/hover cutoff fixes * update style guide link to lib * new fnref styling
Summary
Use Tippy.js for footnotes
Screenshots (optional)
Before:

After:
